package jlaw.client;



import javax.swing.JFrame;
import java.awt.GridLayout;
import javax.swing.WindowConstants;
import java.awt.Rectangle;
import java.awt.Insets;
import javax.swing.JTextField;
import javax.swing.JPanel;
import javax.swing.JLabel;
import java.awt.GridBagConstraints;
import javax.swing.JButton;
//import codi.PantallaLoginControlador;
import java.beans.EventHandler;
import java.awt.event.ActionListener;
import jlaw.*;



public class PantallaLogin {

    public static JFrame crea(PantallaLoginControlador plc) {
      //textfield login
		
		JTextField textField0 = new JTextField("usuari");
              plc.setLogin(textField0);

        JTextField textField1 = new JTextField("contrassenya");
             plc.setPassword(textField1);

        JFrame frame0 = new JFrame("JLaw: Login");

        JPanel panel0 = (JPanel) frame0.getContentPane();

		GridLayout grid1 = new GridLayout( 5, 2, 5, 5 );
		
       
		panel0.setLayout(grid1);
		

        JButton button0 = new JButton();
        button0.setText("Sortir");
        button0.addActionListener(EventHandler.create(ActionListener.class, plc, "cancela"));

        JButton button1 = new JButton();
        button1.setText("Valida");
        button1.addActionListener(EventHandler.create(ActionListener.class, plc, "valida"));
       
        JLabel label0 = new JLabel();
        label0.setText("Password");
       
        JLabel label1 = new JLabel();
        label1.setText("Login");
        frame0.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        frame0.setTitle("New Frame");
		
		//usuari
		panel0.add(label1);
		panel0.add(textField0);
		//password
		panel0.add(label0);

		panel0.add(textField1);
		//sortir i valida
		panel0.add(button0);
		panel0.add(button1);


        return frame0;
    }
}